package org.example.baizhi.controller;

import org.example.baizhi.entity.User;
import org.example.baizhi.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("user")
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping("findAll")
    public String findAll(Model model){
        List<User> users = userService.queryAll();
        model.addAttribute("users",users);
        return "showAll";
    }


    @RequestMapping("findOne")
    public String findOne(String id,HttpServletRequest request){
        User user = userService.find(id);
        request.setAttribute("users",user);
        return "showAll";
    }


}